<!DOCTYPE html>
<html lang="zh">
<head>
 <meta charset="UTF-8" />
 <meta name="viewport" content="width=device-width, initial-scale=1.0" />
 <title>html页面</title>
 <script src="https://cdn.bootcdn.net/ajax/libs/vue/2.6.11/vue.js"></script>
 <style>
   body{
     background-color: #eee;
   }
   #app{
     background-color:#fff;
     width: 500px;
     margin: 50px auto;
     box-shadow: 3px 3px 3px rgba(0 , 0, 0, 0.5);padding:2em;
    }
   .box{
     padding: 1em;
     border:1px solid #ccc;
     margin:1em;
   }
   </style>
 </head>
 <body>
   <div id="app">
     <h2>html页面</h2>
     <hr>
     <div ref="refDiv">
       abc
     </div>
     <hr>
     <com1 ref="refCom1"></com1>
     <hr>
     <button @click="hClick">获取引用</button>
   </div>
   <script>
      Vue.component('com1', {
       data () {
         return {
           msg: '子组件内部的数据'
         }
       },
       methods: {
         changeMsg () {
           this.msg = '子组件内部的数据' + Date.now()
         }
       },
       template: `
        <div>
          我是一个组件 {{msg}}
        </div>
       `
     })
      var vm = new Vue({
        el: '#app',
        data: {
        },
        methods: {
          hClick () {
            console.log(this.$refs)
            console.log(this.$refs.refDiv.innerHTML ="哈哈")
            console.log(this.$refs.refCom1)
            console.log(this.$refs['refCom1'])
            // this.$refs.refCom1.msg = "哈哈哈"
            this.$refs.refCom1.changeMsg()
          }
        }
      })
   </script>
 </body>
</html>